import * as vscode from 'vscode';
import {dedent} from "../../../utils";

// documentation中使用了代码块，代码块中写的事makedown格式，首行不能为空
let bmpTextItems = [
    {
        "label": "BmpText_Create",
        "insertText": dedent`
        GUI:BmpText_Create(\${1:parent}, \${2:ID}, \${3:x}, \${4:y}, \${5:fontColor}, \${6:str}, \${7:fontPath})
        `,
        "documentation": dedent`# 创建Bmp文本
        [在线文档](http://engine-doc.996m2.com/web/#/22/4795)

        | 参数      | 必选 | 类型   | 注释                                   |
        | :-------- | :--- | :----- | :------------------------------------- |
        | parent    | 是   | obj    | 父节点对象                             |
        | ID        | 是   | string | 唯一ID                                 |
        | x         | 是   | int    | 位置 横坐标                            |
        | y         | 是   | int    | 位置 纵坐标                            |
        | fontColor | 否   | string | 字体颜色, [3.40.7版本支持传空]         |
        | str       | 是   | string | 文本                                   |
        | fontPath  | 是   | string | 字体文件路径, 例：\`"fonts/stfont.fnt"\` |

        - 示例代码

        \`\`\`
        local str = "我的名字" or ""
        local Text_name = GUI:BmpText_Create(parent, "Text_name", 0, 0, "#ffffff", str)
        \`\`\`

        `
    }
]





export function getCompletionItems(): vscode.CompletionItem[] {


    const completionItems: vscode.CompletionItem[] = [];
    bmpTextItems.forEach((item: any) => {
        completionItems.push(createFunctionCompletionItem(item.label, item.insertText, item.documentation));
    });
    return completionItems;
}

function createFunctionCompletionItem(label: string, insertText: string, documentation?: string): vscode.CompletionItem {
    const item = new vscode.CompletionItem(label, vscode.CompletionItemKind.Function);
    item.insertText = new vscode.SnippetString(insertText);
    if (documentation) {
        item.documentation = new vscode.MarkdownString(documentation);
    }
    return item;
}
